package core.inputoutput.formatting;


/***
 * An enum designed to make column-width formatting in PDBs easier to understand and use. These are currently
 * based solely on observation and not actual knowledge of PDB files. 
 * @author Julian
 *
 */
public enum Format {

	/**
	 * For any "atomistic" DNA PDB file
	 */
	DNA_ATOMISTIC(new int[]{4,7,5,4,2,4,12,8,8,6,6,10,2}),
	
	/**
	 * For the DNA coarse grain model PDB file based on the format set out by Johnny Maury @NCSU
	 */
	DNA_COARSE_GRAIN(new int[]{4,7,3,6,2,4,12,8,8}),
	
	/**
	 * The generic form of any conect block in a PDB file
	 */
	CONECT(new int[]{6,5,5});
	
	private int[] ColumnWidths;
	Format(int[] widths){
		ColumnWidths = widths;
	}
	
	public int[] getColumnWidths() {
		return ColumnWidths;
	}
	
	/**
	 * Checks to see if the line passed into the method has enough total characters to be split
	 * but this Format --aka line.length > sum(ColumnWidth)--
	 * @param line
	 * @return
	 */
	public boolean canApplyTo(String line){
		int totalWidth = 0;
		for (int i = 0; i < ColumnWidths.length ; i++){
			totalWidth+=ColumnWidths[i];
		}
		return line.length() >= totalWidth;
	}
	
}
